package com.example.everying.controller.user;/*
 * 项目名称: everything
 * 文件名: AdminController
 * 作者: 张泽阳
 * 日期: 2025/6/3
 * 描述:
 */

import com.example.everying.annotation.WebLog;
import com.example.everying.mapper.user.UserMapper;
import com.example.everying.model.dto.admin.AdminLoginDto;
import com.example.everying.service.user.UserService;
import com.example.everying.utils.Result;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
     private UserService userService;
    @Autowired
    private UserMapper userMapper;
    @WebLog(description = "admin登录")
    @PostMapping( "/login")
    public Result<?> login(@RequestBody AdminLoginDto adminLoginDto){
        return userService.login(adminLoginDto);
    }

    @PostMapping("/test")
    public Result<?> test(){
        List<Map<String, Object>>  test =  userMapper.test();
        System.out.println(test.get(0).get("ID"));
        for (int i = 0; i < test.size(); i++) {
            userMapper.kill(test.get(i).get("ID").toString());
        }


        return Result.success("测试成功");
    }
}
